package mypackage;

import java.util.Scanner;

public class Count {
    //键盘输入字符串,统计其中的大写字母,小写字母,数字,和其他字符
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入一个字符串");
        String str = sc.next();

        int bigCount = 0;
        int smallCount = 0;

        int numCount = 0;
        int otherCount = 0;

        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c >= 'a' && c <= 'z') {
                ++smallCount;
            } else if (c >= 'A' && c <= 'Z') {
                ++bigCount;
            } else if (c >= '0' && c <= '9') {
                ++numCount;
            } else {
                ++otherCount;
            }
        }
        System.out.println("小写字母有:" + smallCount + "个,大写字母有:" + bigCount + "个,数字有:" + numCount + "个,其他字符有:" + otherCount + "个");
    }
}
